package com.zhx.common.common.config;


import com.zhx.common.common.interceptor.BlackInterceptor;
import com.zhx.common.common.interceptor.CollectorInterceptor;
import com.zhx.common.common.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private TokenInterceptor tokenInterceptor;

    @Resource
    private CollectorInterceptor collectorInterceptor;

    @Resource
    private BlackInterceptor blackInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加令牌拦截器，并设置其拦截路径为/capi/**
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/capi/**");
        // 添加采集器拦截器，并设置其拦截路径为/capi/**
        registry.addInterceptor(collectorInterceptor)
                .addPathPatterns("/capi/**");
        // 添加黑名单拦截器，并设置其拦截路径为/capi/**
        registry.addInterceptor(blackInterceptor)
                .addPathPatterns("/capi/**");
    }

}
